-
-
Save danielmacuare/373040637d31055da1bd356c4a835fc5 to your computer and use it in GitHub Desktop.
Git Workflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEFORE START WORKING | |
Git fetch origin # Origin is the place from where you cloned your repository. | |
Git merge origin/master # Merge origin/master into your current branch. | |
git pull # Same | |
AFTER FINISH WORKING | |
git add | |
git commit -m "Commit message" | |
Git fetch origin # In case the remote could be ahead of you. Origin is the place from where you cloned your repository. | |
Git merge origin/master # Merge origin/master into your current branch. | |
git push origin master # Push to origin from master. | |
WHEN YOU REMOTE BRANCH IS BEING TRACKED | |
git push # If you are tracking this remote branch. If you have your upstream tacked you can just do git push or git fetch to work with the remotes. | |
WHEN YOU REMOTE BRANCH IS NOT BEING TRACKED | |
git push -u <To_branch> <From_branch> | |
git push -u origin master # -u option is to create the tracking branch. | |
# -u Branch master setup to tack remote branch master from origin. | |
LOG | |
git log --oneline | |
git log --oneline --graph --all --decorate | |
git log --graph --decorate --oneline --abbrev-commit --all | |
BRANCHES | |
git checkout -b <new_branch> # This will create a new branch and will move into it. | |
git branch # To list all the branches of the local repository | |
git Branch -a # Will show you all Remote + Local branches | |
git branch -r # Will show you all the remote branches. | |
git branch <branch_name> # Create a new branch called "branch_name" | |
ls -lah .git/refs/heads # To see the newly created branch | |
cat .git/refs/heads/branch_name | |
UNTRACKING TO IGNORE | |
# Git by default will not ignore already tracked files so the command will remove the copy in my stage but will keep the file in my working Direct | |
# -r options means recursively | |
git rm -r --cached .folder/ | |
git commit -m "Removing folder/ from the staying index" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment