Code Snippet

Just another Code Snippet site

[Git] How-To

To test GIT commands :
learngitbranching.js.org


Create a new branch (local and remote) :

git checkout -b new_branch #< create a new local branch with a copy of your code
git push origin new_branch #< pushes to the server
git push --set-upstream origin new_branch

To define the origin after pushing the new branch :

git branch --set-upstream-to=origin/<branch> new_branch

Clone into specific directory :

git clone http://.... LOCAL_DIRECTORY_NAME

In case of issue with ‘too long filename’ :

git config --system core.longpaths true

Delete a branch (local and remote) :

git branch -d branch_name
git push origin :<branch_name>

Rebase a branch (local and remote) :

rebase branch feature1 to develop

git checkout feature1
git pull
git rebase develop
git pull
git push origin feature1

To merge branch AAA into develop :

git checkout AAA
git pull
git checkout develop
git pull
git merge AAA
git status
git push

This will merge the branch AAA into develop
To do the same without auto commit, add “–no-commit”



37 thoughts on “[Git] How-To

Leave a Reply to Olivier Cancel reply

Your email address will not be published. Required fields are marked *