Above command will list out all the branches in your current working directory that you checked out. The current active branch will have a asterik mark before it.
Say you are working on master branch. Now you need to switch to branch named develop
git checkout develop
Below command will create a new branch locally
git checkout -b newbranch
To push this to remote origin
git push origin newbranch
Below command will delete branch from local repository
git branch -d branchname
git config --global user.email "firstname.lastname@example.org" git config --global user.name "John"
git config --global diff.tool meld git config --global difftool.prompt false
git difftool origin/HEAD master
In above command if you use diff instead of difftool git will show the difference in command prompt
Say a new branch has been added in the remote repository. You need to fetch the remote new branch in your local git repository
git fetch git checkout new_branch
git cherry-pick ba8151da2af0930ac8dd0bxxxxx492bd51360f9
While cherry picking if there are conflicts and say you want to abort the conflict and cherry picking instead of solving it
git cherry-pick --abort
Say you did a
git add some_file.txt and now you want to undo it and don’t want to commit.
git reset some_file.txt
Say you created a branch develop from master
Then there was a commit made to master. Simultaneous commits were made to develop. Now we need to selectively pull changes in develop to master
git checkout feature git checkout -b temp git rebase -i master # Above will drop you in an editor and pick the changes you want ala: pick 7266df7 First change pick 1b3f7df Another change pick 5bbf56f Last change # Rebase b44c147..5bbf56f onto b44c147 # # Commands: # pick = use commit # edit = use commit, but stop for amending # squash = use commit, but meld into previous commit # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted. # git checkout master git pull . temp git branch -d temp
git rebase -i master the i flag tells git to interactively rebase. Thus it opens a editor. Use the instructions at the bottom of the terminal to edit the file.
git reset --hard abcxyz7