DayPath Journal

my little git tricks

The title of this post is trying to tell you that I am not a git expert. These are my cross-platform notes for the subset of git I’ve needed to use so far:

I added a new Develop branch in Visual Studio and the remote cannot see it. From the command line push upstream with the -u switch:

git push -u origin Develop

For detail, see the StackOverflow post. And recall that the -u or --set-upstream sets the origin for the argument-less git pull command—which means that you should only use the -u option only once.

I need to merge master with Develop. What’s important to remember in this scenario is the fundamental concept of git: your local repository is a clone of the remote. This means that a merge operation occurs between branches on your local machine. This explains why you need to checkout and pull from the source branch of the merge:

git checkout Develop
git pull
git checkout master
git pull
git merge --no-ff --no-commit Develop

git status

git commit -m "merging with Develop branch"

git push

For detail, see the StackOverflow answer. These commands also arise in the context of responding to a pull request. Recall thatgit pull is basically the same as git fetch; git merge origin/master.

I added a Develop branch on the remote web client but my local repository cannot see it. I need to fetch the remote repository:

git ls-remote origin

git fetch

git branch -a

I forgot to git-ignore folder foo and I need to delete it from the remote repository. This is done with git rm:

git rm -r --cached ~/foo

I need to know the status of the remote server. When git status returns, “Your branch is up-to-date,” but you are not sure this is accurate, I should try:

git remote update
git status