Skip to content

Instantly share code, notes, and snippets.

@marceloxp
Last active August 9, 2019 15:03
Show Gist options
  • Save marceloxp/bd248c9ee92d3d5ed3a198124532706f to your computer and use it in GitHub Desktop.
Save marceloxp/bd248c9ee92d3d5ed3a198124532706f to your computer and use it in GitHub Desktop.
GIT Commands

GIT Commands

Auto login

# ~/.netrc
machine host.com.br
  login user_login
  password user_passwords

GITU

gedit ~/.bashrc
export PATH=$PATH:/home/umstudio/dev
chmod +x /home/umstudio/dev/gitu.sh

Basic

Command Description
git status List the files you've changed and those you still need to add or commit
git add * Add all pending files to staging
git reset HEAD <file> Unstage file
git commit -m "comentários" Commit files
git push origin master Push commited files

Advanced

Command Description
git branch List local branchs
git branch -r List remote branchs
git branch -a List local and remote branchs
git diff --name-only provisorio..master | zip upload.zip -@ Create Zip
git branch merged master lists branches merged into master
git branch --merged lists branches merged into HEAD (i.e. tip of current branch)
git branch --no-merged lists branches that have not been merged
git log --all --full-history -- **/thefile.* list file inside history

Config

Command Description
git config --global advice.statusHints false Remove Hints

Help

Command Description
git reset --soft HEAD~1 Undo the last commit - keep changes
git reset --hard HEAD~1 Undo the last commit - remove changes

Remote repositories

1 - git remote add local-alias-name [email protected]:local-alias-name-empresa/nome-do-git.git
2 - git fetch local-alias-name master
3 - git push local-alias-name HEAD:master

Tips

  • How to fix GitKraken Inotify Limit Error - upgrading Ubuntu/Linux inotify limits
echo 99999 > /proc/sys/fs/inotify/max_user_watches

Rename Branchs

git branch -m old_branch new_branch         # Rename branch locally    
git push origin :old_branch                 # Delete the old branch    
git push --set-upstream origin new_branch   # Push the new branch, set local branch to track the new remote
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment