Essential git commands, for my own convenience.
Initial commit
After creating a repository on GitHub, do the following:
git init
# add your source code files, for example:
# git add .
git add *.c
git add README.md
# if you haven't already, configure your email and user name
# do not use your account email address here, but one listed at:
# https://github.com/settings/emails
git config --global user.email "<>@users.noreply.github.com"
git config --global user.name "<GitHub full name>"
git commit -m "Initial commit"
git branch -M master
git remote add origin https://github.com/vbresan/<repo name>.git
git push -u origin master
You will be asked for username and password. Use your personal access token instead of password.
Cloning a repository
git clone <https url>
For cloning to current directory:
git clone <https url> .
git config --global credential.helper store
git pull
git add .
git commit -m "Commit comment"
git push
Delete tag
git tag -d <tag-name>
git push --delete origin <tag-name>
Notes on project migration
After copying a project to a new location or sharing the project directory between operating systems, Git can report that files are modified even though there are no changes. This can occur due to line endings or file permission changes. File permissions are checked by default, but you can verify yourself by running:
git config --get core.fileMode
You can tell git to ignore file permission changes by running the following command:
git config core.fileMode false
No comments:
Post a Comment