Saturday, April 15, 2017

Git tips


Set up Git

Removing non-repository files with git?

--------------------------------------------------------------------------------------------------------------

How do I discard unstaged changes in Git?

Ans: 
a)For a specific file use:
git checkout path/to/file/to/revert
b)For all unstaged files use:
git checkout -- .
Make sure to include the period at the end.
c)To check out specific files
git checkout -- cats.html index.html
---------------------------------------------------------------------------------------------------------------------
git branch -a                                     -- lists all branches
git push origin :branchnamehere     -- to delete the remote branch(note semicolin before                                                                                    branchname)

git remote show origin                     -- checks for stale branches tracking origin
git remote prune origin                     -- to clean up deleted remote branches

git tag                                                           -- list all tags
git tag -a v0.1.2.3 -m "versioncomments"   -- add a new tag
git push --tags                                              -- to push new tags


---------------------------------------------------------------------------------------------------------------------
git fetch      -- pulls down the history but does not merge

rebase vs Merge
Rule of thumb:
1. When pulling changes from origin/develop onto your local develop use rebase.
          git pull --rebase

2. When finishing a feature branch merge the changes back to develop.

---------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------


---------------------------------------------------------------------------------------------------------------------



---------------------------------------------------------------------------------------------------------------------



No comments:

Post a Comment

Devops links

  Build Versioning in Azure DevOps Pipelines