To be able to work and moreover understand the underlying mechanics of powerful GIT tool, You should recognise how some actual commands work even if U use GUI to perform for ex git-flow. In different situations You may need to execute some commands via terminal on the server - the best way to do this is to know basic commands, here we go:
git init - initialise local git repository
git remote add origin <url> - add remote url to Your local copy
git remote set-url origin <url> - set another (change) remote url
git remote -v - list remote urls
git add - add file to branch
git commit - commit all changes to local repo
git push - push out all changes to remote
git push origin master --force - push latest changes to remote branch overriding it, use with caution
git add . && git commit -a -m 'some comment' && git push - combination of all commands to sync local and remote branch
git pull - pull all changes from remote
git pull origin <branch> - pull particular branch
git reset --hard HEAD - reset all changes to the latest commit in current branch
git log -p or git log -p <filename> - see latest changes to file(s)
git clean -df - clean all local changes
git branch -d the_local_branch - delete a local branch
git push origin :the_remote_branch - remove a remote branch semicolon is mandatory
git revert --strategy resolve 028fd6c - sometimes the shit happens, this command saved my life in those moments =)
// renaming branch remotely
git push --set-upstream origin new_branch - Push the new branch, set local branch to track the new remote
// =====
// convenient command in case U need to remove cached files from .gitignore and there are a lot
git rm --cached `git ls-files -i --exclude-from=.gitignore`
That's it, hope this information helped anyone to collect their knowledges about GIT.
git init - initialise local git repository
git remote add origin <url> - add remote url to Your local copy
git remote set-url origin <url> - set another (change) remote url
git remote -v - list remote urls
git add - add file to branch
git commit - commit all changes to local repo
git push - push out all changes to remote
git push origin master --force - push latest changes to remote branch overriding it, use with caution
git add . && git commit -a -m 'some comment' && git push - combination of all commands to sync local and remote branch
git pull - pull all changes from remote
git pull origin <branch> - pull particular branch
git update-index --assume-unchanged <file> - mark file/dir as unchanged
git update-index --no-assume-unchanged <file> - the backward of previous command
git rm --cached <file> - remove file in remote repo
git rm -r --cached <file> - remove dir in remote repogit reset --hard HEAD - reset all changes to the latest commit in current branch
git log -p or git log -p <filename> - see latest changes to file(s)
git clean -df - clean all local changes
git tag -a v1.2.5 -m 'comment’ - create tag
git push origin --tags - push created tag to remotegit branch -d the_local_branch - delete a local branch
git push origin :the_remote_branch - remove a remote branch semicolon is mandatory
git revert --strategy resolve 028fd6c - sometimes the shit happens, this command saved my life in those moments =)
// renaming branch remotely
git branch -m old_branch new_branch - Rename branch locally |
git push origin :old_branch - Delete the old branch |
// =====
// convenient command in case U need to remove cached files from .gitignore and there are a lot
git rm --cached `git ls-files -i --exclude-from=.gitignore`
That's it, hope this information helped anyone to collect their knowledges about GIT.