Git Commands

阅读更多
First person Setup
1. Set up a new repository from local to remote
git init
git add --all
git commit -m "Initial Commit from SVN migration"
git remote add origin ssh://[email protected]:7999/ep/mfa.git
git push -f origin master

git config --global user.name "Your Name Comes Here"
git config --global user.email [email protected]
Git help clone

2. add submodule
git submodule add [repo URI] [folder name]
eg: git submodule add ssh://[email protected]:7999/ep/portal-common.git portal-common

Other users to follow
1. Clone an existing remote repository to local
git clone ssh://[email protected]:7999/ep/portal-project.git portal-project

2. close submodules as well if needed
Option a: After getting into submodule folder, run 'git submodule init' and then 'git submodule update'
Option b: directly pass --recursive to the git clone command in above step
eg. git clone --recursive ssh://[email protected]:7999/ep/reverse-proxy.git reverse-proxy

Create a remote branch via local
git push -u origin 20160422_Release

Tag
git tag -a V1.0.0 -m 'tag test'
git push https://username:pwd@hostname/EsOrg/au-test7.git V1.0.0

http://digitaldrummerj.me/git-sync-fork-to-master/
1) git fetch upstream: fetch all of the changes from the original repository. Note that commits to the original repository will be stored in a local branch called, upstream/master
2) git merge upstream/master

Remove latest commmit
1) git log -3 // show latest 3 commits
2) git reset --hard HEAD~1 (remove latest commit)
3) git push origin master -f

Reset remote origin
git remote set-url origin https://host/orgName/repoName.git

Checkout part of repository
svn export "https://github.wdf.sap.corp/{org}/{repo}/trunk/{path}"  ./{local_folder}/  --force
svn export "https://github.wdf.sap.corp/{org}/{repo}/branches/b1902/{path}"  ./{local_folder}/  --force

你可能感兴趣的:(Git Commands)