Skip to content

Instantly share code, notes, and snippets.

@Jongbhin
Last active August 8, 2023 06:38
Show Gist options
  • Save Jongbhin/d17562cd23cf9f86a67e9656fc972a18 to your computer and use it in GitHub Desktop.
Save Jongbhin/d17562cd23cf9f86a67e9656fc972a18 to your computer and use it in GitHub Desktop.
[Git reference] #git #reference

Git add remote

git remote add REMOTE-ID REMOTE-URL
git remote set-url --add --push all REMOTE-URL-1
git remote set-url --add --push all REMOTE-URL-2
# git remote set-url --add --push all git@175.126.56.233:CVPR/clean-scoring-v2-api.git

Git fetch all branches

git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
git push --all all

Git initial repo - My code is ready to be pushed

cd existing-project
git init
git add --all
git commit -m "Initial Commit"
git remote add origin ssh://git@bitbucket.11stcorp.com:7999/stin/clean-scoring-kafka.git
git push -u origin master

Git initial repo - My code is already tracked by Git

cd existing-project
git remote set-url origin ssh://git@bitbucket.11stcorp.com:7999/stin/clean-scoring-kafka.git
git push -u origin --all
git push origin --tags

Configure Git for the first time

git config --global user.name "박종빈(Jongbhin Park)/Machine Intelligence팀/11ST"
git config --global user.email "jongbhin@sk.com"

git id pwd save

# Run the following command to enable credentials storage in your Git repository:
git config credential.helper store

#To enable credentials storage globally, run:
git config --global credential.helper store

git 패스워드 리셋

# 프로젝트 별로는 아래 실행
git config --unset credential.helper

git 사용자 설정

git config --global user.name "박종빈(Jongbhin Park)/Machine Intelligence팀/11ST"
git config --global user.email "jongbhin@sk.com"
git config user.name "박종빈(Jongbhin Park)/Machine Intelligence팀/11ST"
git config user.email "jongbhin@sk.com"

리포별로 유저 패스워드 설정

Sometimes you may need to use different accounts on the same Git server, for example your company’s corporate account on github.com and your private one.
To be able to configure usernames and passwords for different Git repositories on the same Git server you can enable the useHttpPath option.

By default, Git does not consider the “path” component of an http URL to be worth matching via external helpers. This means that a credential stored for https://example.com/foo.git will also be used for https://example.com/bar.git. If you do want to distinguish these cases, set useHttpPath option to true (source)

Run the following commands to configure Git credentials storage and separate credentials for different repositories on github.com:
git config --global credential.helper store
git config --global credential.bitbucket.11stcorp.com.useHttpPath true
The usernames and passwords for different GitHub repositories will be stored in ~/.git-credentials file separately on their own lines:

https://<USERNAME>:<PASSWORD>@github.com/path/to/repo1.git
https://<USERNAME>:<PASSWORD>@github.com/path/to/repo2.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment