How to use git
Checkout and push local changes
Follow the steps bellow to push your changes from local development
Check out develop branch
git checkout origin develop
Create a new branch ( feature branch)
git checkout -b new-feature-branch
Once you finish development
you can check status using
git status
then add the changes
git add --all
Commit changes to your feature branch
git commit -m "message of the commit"
Checkout local develop branch
git checkout develop
Pull form remote develop - to incorporate others change
git pull origin develop
Then checkout your branch
git checkout new-feature-branch
Merge develop to the new feature branch - fix any conflicts if exist(if any you will need to commit them after fixing)
git merge develop
Push the chages to the remote feature branch
git push origin new-feature-branch
Then create a merge request using the github site.
Delete branches
git branch -d new-feature-branch
Delete branches remotely
git push origin --delete new-feature-branch |or| git push origin :new-feature-branch
Stash code
git stash
git stash list
git stash apply
Roll back local and remote git commits
If you want revert last commit listen:
Step 1:
Check your local commits with messages
git log
Step 2:
Remove last commit without resetting the changes from local branch (or master)
git reset HEAD^
OR if you don't want last commit files and updates listens
git reset HEAD^ --hard
Step 3:
We can update the files and codes and again need to push with force it will delete previous commit. It will keep new commit.
git push origin branch -f