Tips and Tricks for git
GitHub is a internet hosting provider for software development and version control using git. It provides distributed version control, source code management, issue tracking and many more. This is now the number one version control provider. Here, I will discuss on tips and tricks of git
- Discard unstaged changes in Git?
For all unstaged files in current working directory use:git checkout -- .
- Merge your local uncommited changes
git stash
git pull
git stash apply
- Remove cached files
- Go to the directory and run the following command
git rm -r --cached obj/
- Go to the directory and run the following command
- Move git repository to another repository with history
cd existing_repo
git remote rename origin old-origin
git remote add origin http://192.168.104.33/gitlab-instance-f3a04ace/Monitoring.git
git push -u origin --all
git push -u origin --tags
- Undo the commit, which has not been pushed yet.
- Check how many commit
$ git log // Type q to exit this screen
- Remove commit and keep file staged
$ git reset --soft HEAD~1
- Remove commit and unstaged file
$ git reset HEAD~1
- Remove commit and discard changes
$ git reset --hard HEAD~1