Git-Github integration and commands
…if create a new repository with the command line:
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/username/repo_name.git
git push -u origin master
…or push an existing repository from the command line:
git remote add origin https://github.com/username/repo_name.git
git push -u origin master
Sync issue:
Sometimes we come across the Sync issue which throws an error when Push for the 1st time e.g:
Push to origin/master was rejected
Refusing to merge unrelated histories
Solution:
Simply commit all files first and pull your repository to sync with your codebase. Once pull done, then push to origin.
Delete or update local and Remote branch names:
Rename your current local branch:
git branch -m new-name
Rename your different local branche:
git branch -m old-name new-name
Delete the remote branch old name and update with new-name:
git push origin :old-name new-name
Reset the upstream branch for the new-name local branch:
git push origin -u new-name
ORgit push --set-upstream origin new_branch
Commit details and latest tag:
To see all commits history including commit hashcode:
git reflog
To find the latest tag information:
git describe
Let’s make happily coding journey with a clap :)