forked from haikuports/haikuports
-
Notifications
You must be signed in to change notification settings - Fork 0
Using git commands
Schrijvers Luc edited this page Jan 21, 2020
·
24 revisions
- git remote -v (this will tell you your remote branch, usually origin)
- Sometimes you forked a github repository to your own account on github, to make sure your master branch is up to date with the upstream branch you need to add the upstream branch with git.
- git remote add upstream "url git upstream" (check with remote -v to make sure you've got origin and upstream url's)
- git pull upstream master (pull the latest changes to your local origin branch)
- git push origin master (push the latest changes to your remote origin branch)
- Check with "git status" if your local branch is up to date with the remote branch.
- git checkout master (In case you already have branches installed make sure you switch to master branch)
- git pull (make sure your master branch is up to date with remote master branch)
- git status (check if there aren't any changes)
- git checkout -b "new_branchname" (create local new branch)
- Make your changes in your local branch and check again after that with "git status" (it will tell you what you've changed)
- git add "name_of_changed_file"
- git rm "name_of_deleted_file" (if needed)
- git commit -m "commit message"
- git push origin "new_branchname" (provide user name and password when asked for, then you will see git pushing the changes to a new remote branch)
- git branch (will tell you your local branches)
- git branch -v (will tell you your remote branches)
- git checkout "branchname" (will change your working branch to "branchname")
- Sometimes after you committed a change to github and find out you need to make extra changes but don't won't to commit a second commit for a pull-request, this can be done with:
- git commit --amend (this will open an editor and shows you your initial commit message, just close, save and push your changes to github)
- git push -f origin "branchname"
- Sometimes it's handy to commit multiple commit messages (for others to track the changes) but before a merge it's better to squash them all together in one commit:
- git checkout "branch" (checkout your remote branch)
- git log (checkout the number of commits)
- git rebase -i HEAD~n (where n is the number of commits you've made)
- Then in the editor replace pick with squash to each line you want to squash the commit with the previous one. Close the editor and save.
pick d02f41c78 lua, bump version
squash 08dcc99bd change copyright according to -v, add test
- In the next editor comment the lines out you don't want into the commit with "# ". Close the editor and save.
# This is a combination of 2 commits.
# This is the 1st commit message:
lua, bump version, add test (added "add test" to the commit message)
# This is the commit message #2:
# change copyright according to -v, add test (added "# " in the beginning of the line so it will be ignored)
- git push -f origin "branch" (to push your local changes to your remote branch)
- After you successfully pushed your local changes to your remote fork head over to github, github will show you your local changes and provide you with a link to create the pull request.
- Check the actual pull request before filing it to see the changes made by you are what you want them be.
- git push origin :"branchname" (this will delete the remote branch)
- git branch -D "branchname" (this will delete your locale branch)
- Pull another remote branch from Github to a local branch
- git clone "repository"
- cd "repository
- git fetch origin (make sure the origin is setup to track remote repository with git remote -v)
- git checkout --track origin/"remote_branch"