Sunday, 9 December 2018

Useful GIT Commands

Reset GIT credentials

# git config --global --unset credential.helper


Useful GIT workflows

1. create dir

2. cd dir

3. git clone repo to dir

4. git branch -a (to see list of branches)

5. git checkout {$ a branch name on git}

6. git checkout -b {$ your branch name} {$a branch name on git} 
(Create your branch of the content of the git branch)

7. Your git should be at your branch

8. to commit, git add . (add all changes)

9. git commit -m "commit messages"

10. (if want a tag, create tag locally for this commit) git tag v0.19

11. git push -u origin {$ your branch} 
(do it only for first time, because branch not up on git)

12.(if your branch is already up) just git push(to push changes to git)

13. every time new tag is created locally,  git push  origin v0.19(tag name)

GIT Fetch From Upstream


//upstream only works if two repo have common commits, if not use
(git merge upstream --allow-unrelated-histories
(only need to add --allow-unrelated-histories once -> the second time, 
two branch will have same commit))

git clone Child repository to your own local folder
git status
(Only done once:)
git branch -a
git checkout JX-dev 
(make sure this child branch name is the same name as parent branch)
(start of only done once)
git remote add upstream https://MyparentGITREPO.com
(end of only done once)
git fetch upstream
git merge upstream/JX-dev(Parent branch name)

git push -u origin {$ JX-dev } from local to remote for first time
// Check for parent tags
git tag
git push origin v1.x.x



GIT solve conflicts

(If there are conflicts. find conflicting file, 
<<<>> branch, fix the issue, then remove
those === <<< >>>>, and then a ) git add .  b)git commit -m "merged conflict"  )
git push (first time(if there is no such remote branch) use  git push -u origin  )



git add.
git commit -m
git push
GIT Create Tag

// Create new tag on local
git tag v1.0.3
// Push tag to remote
git push origin v1.0.3


No comments:

Post a comment