Friday, October 20, 2023

Git commands - for setup and daily work

 This article is just to collect some of the Git commands that are being used on a regular basis.

Git commands for daily work

git clone <https link to repo> (clone a remote repo. Make sure you’re in the correct directory when running)

git pull (sync the latest changes from remote repo)

git checkout -b feature/new_branch_name (create new feature branch)

git checkout main (switch to main branch)

git add -A (pre-commit command to add all new files to local staging, run this before local commit)

git commit -a -m "adding a test file" (commit all files to local branch and add a message)

git push --set-upstream origin feature/testingbranch (publish local branch to remote repo, use the same name as the current feature branch)

git branch -d localBranchName (delete local branch)

git push origin --delete remoteBranchName (delete branch remotely)

git branch -l (list branches)

Git commands configuring Git

git config --global "First Last" (user name and email should be set up as a one time config)

git config --global <>

git config --global core.longpaths true (fixes an error with long path names)

git config --list (show git config)

git config --list --show-origin (show git config including where variables are defined)

git config --global http. https://someaddress (this is a proxy related setting)

git config --global http. negotiate (this is a proxy related setting)

git config --global http. true (this is a proxy related setting)

git config --global --edit (edit the global config file in VI editor)

git config --global --replace-all "username" (replaces current user name)

git config --global --replace-all <>

git config --unset-all credential.helper (unset named settings)

git config --global --set credential.helper (set the credentials helper type)


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.