What does git push -u mean?
2022-03-12
Question I have two different versions of git. In the 1.6.2 version, git push does not have the -u option. It only appears in the 1.7.x version. From the docs, the -u is related to the variable branch.<name>.merge in git config. This variable is described below: Defines, together with branch.<name>.remote, the upstream branch for the given branch. It tells git fetch/git pull which branch to merge. What is an upstream branch ?…
Git: Set local user.name and user.email different for each repo
2022-03-11
Question I'm currently working on 2 projects, which expect that I configure my local username and email with different data when I push to them. For that I'm updating my config all the time like: git config --local user.email "namelastname@domain.example" Since they are different repositories, is there a way I could define an local email for each repository? Maybe in the .gitconfig? Answer For just one repo, go into to the relevant repo DIR and:…
How to cancel a local git commit?
2022-03-11
Question My issue is I have changed a file e.g.: README, added a new line 'this for my testing line' and saved the file, then I issued the following commands: git status On branch master Changed but not updated: (use “git add <file>…” to update what will be committed) (use “git checkout – <file>…” to discard changes in working directory) modified: README no changes added to commit (use “git add” and/or “git commit -a”)…
Explain which gitignore rule is ignoring my file
2022-03-10
Question Is there any way to see why some file is getting ignored by git (i.e. which rule in a .gitignore file is causing the file to be ignored)? Imagine I have this (or a much more complex scenario, with hundreds of folders and tens of .gitignore files: / -.gitignore -folder/ -.gitignore -subfolder/ -.gitignore -file.txt If I run git add folder/subfolder/file.txt git may complain of it being ignored: The following paths are ignored by one of your .…
gpg failed to sign the data fatal: failed to write commit object [Git 2.10.0]
2022-03-09
Question I followed few articles over the pretty attributes on Git 2.10 release note. Going through which upgraded the git to 2.10.0 and made changes to global .gitconfig resulting as follows - [filter "lfs"] clean = git-lfs clean %f smudge = git-lfs smudge %f required = true [user] name = xyz email = abc.def@gmail.com signingkey = AAAAAAA [core] excludesfile = /Users/xyz/.gitignore_global editor = 'subl' --wait [difftool "sourcetree"] cmd = opendiff \"…
How do I clone a specific Git branch? [duplicate]
2022-03-09
Question This question already has answers here: </div> How do I clone a single branch in Git? (27 answers) Closed 9 years ago. Git clone will clone remote branch into local. Is there any way to clone a specific branch by myself without switching branches on the remote repository? Answer git clone -b <branch> <remote_repo> Example: git clone -b my-branch git@github.com:user/myproject.git With Git 1.7.10 and later, add --single-branch to prevent fetching of all branches.…
Your branch is ahead of 'origin/master' by 3 commits
2022-03-09
Question I am getting the following when running git status Your branch is ahead of 'origin/master' by 3 commits. I have read on some other post the way to fix this is run git pull --rebase but what exactly is rebase, will I lose data or is this simple way to sync with master? Answer You get that message because you made changes in your local master and you didn't push them to remote.…