Git-hub issue: Shows 87 files changed of my laravel project - laravel

I am new to git-hub and when I create a pull request it shows a large amount of file changed, I am working on Laravel5 and being a trainee in a company I have to send the PR to my team head. So, How to save a fresh Laravel file in master branch and then after doing 1 or 2 changes I commit and generate PR?
Showing 87 changed files with 834 additions and 2,357 deletions

First, if you generate a PR, do so from a dedicated branch, not from master.
Second, whenever you are pushing to a fork (to make a PR), rebase your local branch first on top of the original repo branch.
cd /path/to/local/repo
git remote add upstream /url/original/repo
git fetch upstream
git checkout mybranch # in your case, for now master
git rebase upstream/master # rebase on top of the destination branch
# which will receive and integrate your PR
git push --force origin mybranch
Then make your PR: the diff will be only your work, as opposed to a delta representing evolution on upstream done while you were preparing your fix.

Related

The local repository is out of date when push the code even after pull is completed

1.Pull the latest code[
2.Commit the new code
3. When tried to push the code to bitbucket repository getting message "Local repository out of date[![enter image description here]
**
tried bothway Xcode push and cmd based push but no luck still getting this weird message
Note:
Xcode 12.4,
bit bucket
I don't understand, the image shows after the "pull"? If not, please edit your question and place the image in the correct place.
That message can be because someone else have pushed to your repo after the last time you pulled from it. You will need to revert all the X commits that you have done after your last succed push (save the work in another branch or whatever):
git reset --hard HEAD~X
Or reset your local branch to directly match your remote branch:
git reset --hard origin/remote-branch-name
Pull from the repo, make your commits and then you will be able to push again.
You have another option: PULL FORCE!!!
If you alredy known the "push --force" command, then pull force will sound you familiar, but in reality doesn't exist something like "pull --force", but exist a way to replicate that functionality in pull requests:
git fetch --all
git reset --hard origin/master
git pull origin master
(Replace "master" by your branch name)
With that command you overwrite your git history to match exactly the history of your remote repository branch. That will overwrite local changes (the ones that you have not pushed yet) and then you can make your commits and push them.
You can avoid this ackward situation by always working in a new branch only for your work, and when you need to integrate your changes you can make rebase or merge.
There are changes in your local repository that are not on the remote and vice versa, causing a conflict in your history.
You could try the following in your local repository (assuming your remote is called origin):
Make sure your local changes are committed (git commit -am "Some commit message")
Create a new branch (git branch new-branch-name)
Fetch the remote branch (git fetch origin)
Reset the target branch to the version on the remote (git reset --hard origin/target-branch-name)
Merge your newly created branch (git merge new-branch-name)
Push your changes to the remote (git push origin target-branch-name)
Finally resolved it by push the commits to the new PR and then merged the code with old PR

Pushing new git changes without checking out master (Xcode/Bitbucket)

I'm new to git and I started making changes to a previous commit without creating a new branch. (oops)
Now my local version is no longer the current master. Trying to push the changes gives me the following error: "The current branch could not be determined." If I check out the current master, I can commit as normal, but I lose all the changes I made after the mistake (but save in a backup local copy).
How do I push my new changes without checking out the current master? (branch, merge, etc.)
Or how do I connect my existing project to a new repository and start over?
(I tried changing the repository location to a new url, but I still have to check out the master to push..)
If the answer requires terminal commands, baby steps would be appreciated.
Here is the simple solution I use always - when I start developing on the master branch and forget to create new branch.
1. git stash
2. git checkout -b new-branch-name
3. git stash apply
4. git add *
5. git commit -m "commit"
6. git push origin new-branch-name .
That's all :)
Also as you are beginner you should play and learn git by playing this game and you will solve your problems related git by yourself :)

Unable to update my GitHub from my Mac

Why am I unable to update my GitHub from my Mac?
git status produces the following:
On branch master Changes to be committed: (use "git reset HEAD
<file>..." to unstage)
new file: file.test
Untracked files: (use "git add <file>..." to include in what will be
committed)
.DS_Store
git push produces the following;
fatal: The current branch master has no upstream branch. To push the
current branch and set the remote as upstream, use
git push --set-upstream origin master
You need to git add ., then git commit -m "My commit message", then git push -u origin master.
That will set the upstream to the origin/master. Moving forward, just git push shall suffice
Git works through commits - which are basically snapshots of what your repository looked like at a given point in time. You need to commit the files to your repository before you can actually push them to GitHub.
So your first step is to add the files to the "Staging Area" with
git add file.text # you can do git add . but this will add all files which you may not always want
Now you can check the current status of the "Staging Area" with
git status
This will let you make sure that you are only committing the changes that you want added.
Now you can commit the changes. Committing will only 'save' the files that are in the Staging Area.
git commit -m "A useful description of what you did since your last commit"
Ok so now you're ready to push. Assuming you cloned from GitHub you can just run
git push origin master
But if you created this repository with git init you will need to tell git that you have a remote repository somewhere. Do this by running
git remote add https://github.com/<usernane>/<repo_name> origin
This origin is the name you would like to associate with the remote repository. 'Origin" is the most common but you may have other remotes like "backup" or "code_review" for different use cases.
Once you have added the remote repo, you can actually push to it with
git push origin master
Again, origin is the name for your remote repo and 'master' is a 'branch' name.
You can add the -u flag which will make it so that git assumes you want to push to origin. So in the future you would only need to run
git push
Listen to the error messages. :)
You currently have one untracked file, .DS_Store which I happen to know is a system file, so you may want to add that to your .gitignore
As for trying to push upstream, you need to set your upstream for each branch, so you simply need to type the command
$ git push --set-upstream origin master
then do a simple
$ git push
to send your changes to github.
If the branch you are pushing to online is ahead of you, then you may need to do a git pull to get grab the changes, before you do a git push.

How to merge from upstream branch?

Here is my git setup (we use Git + Atlassian Stash in our corporate network):
upstream:
master
origin (my fork of 'upstream'):
master
branch1 (branch of master, with a few commits on top of it)
clone (local; clone of 'origin'):
master
branch1 (ahead of 'origin:branch1' by 1 commit)
What I want to do:
I want to merge upstream:master -> clone:branch1. I know there will be conflicts with this merge (since I changed files in my branch1 that others have changed in upstream). Once this is done I hope to push my changes back to origin:branch1, which will include my 1 commit + latest base from upstream (I want to keep up to date with the master branch, since that's the one I branched from). Along with this I want it to be a rebase, so that the commit history is clean and doesn't spider-web all over the place.
Another note is that I do not use git command line directly. On Windows, I'm using SmartGit, so if anyone knows instructions for that tool that would be most ideal.
How can I properly merge like I have described above?
If no one else has cloned or is working with branch1, you can rebase it on top of master, once you have updated master to upstream/master.
First, fetch upstream (SmartGit: Remote/Pull, select "Fetch Only")
Then reset master to upstream/master (SmartGit: Local/Reset)
Now rebase branch1 on top of master (SmartGit: In the Branches view, you can right-click on a branch like master and select Rebase HEAD to rebase your current HEAD onto the selected branch master)
Resolve merge conflicts if necessary.
Finally push (force the push) of branch1 to origin (SmartGit: In the context menu of the Branches view, you can invoke Push and Push To on local branches).

Git Status does not show 'ahead of' after edit and commit to local repo

Our company's workflow is to clone master branch into a _Test branch as we work on new features and we continually push/share this _Test branch until a set of features are complete and approved by client, then we merge to master branch and build and publish our sites. Then rinse and repeat.
The problem I'm having is git status isn't showing the correct ahead/behind (or more likely, I may not understand what it is supposed to show) while working on the _Test branch. If I do the following steps:
git checkout _Test
git pull --rebase origin _Test # get latest code
edit some files
get commit -am "Test commit"
git status
After step four, the git output is
[_Test d6fa824] Test commit
1 file changed, 1 insertion(+), 1 deletion(-)
Then after step five, the git output is
# On branch _Test
nothing to commit, working directory clean
Shouldn't it say?
Your branch is ahead of 'origin/_Test' by 1 commit.
If I look at qgit or gitk they show origin/_Test and remotes/origin/_Test respectively (correctly) 1 commit behind the last test commit. I'm running msysgit and git version outputs:
git version 1.8.1.mysysgit.1
So I'm confused why the output from git commit doesn't state that I'm ahead of origin/_Test (when obviously I am since I just committed) and why git status doesn't state same information.
Let me know if I need to provide any more info.
I resolved this problem.
You basically need to set up git tracking using
git branch --set-upstream *branch_name*
Read my full explanation here

Resources